package com.ruoyi.iot.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.iot.domain.DeviceDataRequest;
import com.ruoyi.iot.service.IFacDeviceMonitorDataService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@AllArgsConstructor
@RestController
@RequestMapping("/iot/facmonitordata")
public class FacDeviceMonitorDataController {
    private final IFacDeviceMonitorDataService facDeviceMonitorDataService;

    @PostMapping("last")
    public AjaxResult page(@RequestBody DeviceDataRequest request){
        Map<String,Object> list=facDeviceMonitorDataService.getDeviceLastData(request);
        return AjaxResult.success(list);
    }
    /***
     * 播放视频
     */
    @PostMapping("playVideo")
    public AjaxResult playVideo(@RequestBody DeviceDataRequest request){
        HashMap list=facDeviceMonitorDataService.playVideo(request);
        return AjaxResult.success(list);
    }

    @PostMapping("/monitorPageData")
    public AjaxResult getPageData(@RequestBody DeviceDataRequest request) {
        Map<String,Object> dataMap =facDeviceMonitorDataService.getDevicePageData(request);
        return AjaxResult.success(dataMap.get("data"));
    }
}
